package com.fz.us.oa.core.dao.common.impl;

import com.fz.us.admin.base.dao.impl.BaseDaoImpl;
import com.fz.us.oa.core.dao.common.FileManagerDao;
import com.fz.us.oa.core.entity.common.FileManage;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;

import java.io.File;

/**
 * Dao实现类 - 附件
 * ============================================================================
 * 
 * @author qshihua
 * @version 0.1 2016-9-1
 * ============================================================================
 */

@Repository
public class FileManagerDaoImpl extends BaseDaoImpl<FileManage, String> implements FileManagerDao {

	private String pathname;
	private File file;
	
	//删除 处理附件
	@Override
	public void delete(FileManage fileManage) {
		pathname = fileManage.getUrl();
		if(!StringUtils.isEmpty(pathname)){
			file = new File(pathname);
			file.delete();
		}
		super.delete(fileManage);
	}

	@Override
	public void delete(String id) {
		FileManage fileManage = load(id);
		this.delete(fileManage);
	}

	@Override
	public void delete(String[] ids) {
		for (String id : ids) {
			this.delete(id);
		}
	}
	
}
